{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# SWING Example Notebook\n",
    "\n",
    "Swing components are now supported in Kotlin Notebooks.\n",
    "\n",
    "The support will differ depending on the session run mode (see Notebook Plugin Settings):\n",
    "\n",
    "- **Run in a separate process (default):** In this mode, Swing support is limited.\n",
    "  It is only possible for the kernel to render a static screenshot of the current state\n",
    "  of the UI. This will be returned as standard notebook output image.\n",
    "\n",
    "- **Run in the process:** In this mode we can render the Swing output directly in IDEA as\n",
    "  notebook output, and it will be possible to interact with it. Beware, that due to how\n",
    "  Swing works internally, there are restrictions to how Swing components are configured.\n",
    "  See the Warnings sections for more details.\n",
    "\n",
    "  This mode is currently hidden behind a Registry flag `kotlin.notebook.allow.embedded.kernel`\n",
    "  which must be enabled first. Then the Run Mode can be changed in the Notebook settings.\n",
    "  It is being moved to the Notebook toolbar, so its location might vary depending on the\n",
    "  plugin version.\n",
    "\n",
    "Regardless of the mode used, A static image of the Swing component will be stored inside\n",
    "the normal notebook file as the cell output. So if you share the file with others or on\n",
    "Github, this is what they will see when the file is opened for the first time.\n",
    "\n",
    "Note, if the Kotlin Notebook is run outside IntelliJ, e.g. inside Jupyter. It runs as the\n",
    "though in \"Run in a separate process\"-mode.\n",
    "\n",
    "\n",
    "## Warnings\n",
    "\n",
    "* Due to the way Swing works, it isn't possible to have the same Swing component shown in multiple outputs. The Swing rendering engine will remove it from earlier outputs and only show it in the latest one.\n",
    "\n",
    "* EXIT_ON_CLOSE does not work on `JFrame`, instead `DISPOSE_ON_CLOSE` must be used.\n",
    "\n",
    "* When creating inline Swing components, `size` must be set to display it.\n",
    "\n",
    "* Starting Swing components from inside the IDEA process will make them inherit IDEA's theme. There is\n",
    "  currently no way to override this.\n",
    "\n",
    "\n",
    "# Compose Interop\n",
    "\n",
    "Kotlin Notebooks does currently not support the Compose Compiler Plugin. This means it isn't possible to create `@Composeable` functions directly. Enabling this require changes in the Kotlin Compiler that is coming in Kotlin 2.1. See https://youtrack.jetbrains.com/issue/KTNB-650/Compose-Renderers-API for more information.\n",
    "\n"
   ]
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-10-10T14:26:30.348801Z",
     "start_time": "2024-10-10T14:26:30.172986Z"
    }
   },
   "cell_type": "code",
   "source": [
    "// Display a JFrame\n",
    "// Note, this will not be shown in the notebook, but will be shown as a floating window.\n",
    "// To render the JFrame inline, you will need to pull out the content panenl of the JFrame\n",
    "// but be aware that the size might be wrong.\n",
    "import java.awt.Color\n",
    "import java.awt.Dimension\n",
    "import java.awt.GraphicsConfiguration\n",
    "import java.awt.RenderingHints\n",
    "import java.awt.image.BufferedImage\n",
    "import java.io.File\n",
    "import javax.swing.*\n",
    "\n",
    "val frame = JFrame(\"Color Changer\")\n",
    "frame.defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE // EXIT_ON_CLOSE doesn't work\n",
    "frame.preferredSize = Dimension(300, 200)\n",
    "val panel = JPanel()\n",
    "//panel.preferredSize = Dimension(300, 200)\n",
    "val button1 = JButton(\"Button 1\")\n",
    "val button2 = JButton(\"Button 2\")\n",
    "val button3 = JButton(\"Button 3\")\n",
    "button1.addActionListener { panel.background = Color.RED }\n",
    "button2.addActionListener { panel.background = Color.GREEN }\n",
    "button3.addActionListener { panel.background = Color.BLUE }\n",
    "panel.add(button1)\n",
    "panel.add(button2)\n",
    "panel.add(button3)\n",
    "frame.add(panel)\n",
    "frame.pack()\n",
    "frame.isVisible = true\n",
    "frame // Frames are shown outside IDEA"
   ],
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlgAAAFYCAYAAACPjoJBAAAWXUlEQVR4Xu3d6bfkdJ0HYP8fu2Aaug/jHI59gAH70ICN2LgwLrgioqwqKgoDsimbKC7QQLOqjDMgsoqCCijgAiiiLG6z6DvP/AeZ/laZmtzkVnVx7/eXitfnxXOwK6lU3fLzSz5JJalXvXr0DxUAAHle1X4AAID1UbAAAJIpWAAAyRQsAIBkChYAQDIFCw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oWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACS/R+gT4piFf0uOwAAAABJRU5ErkJggg==",
      "application/vnd.idea.swing": "1"
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-10-10T14:26:33.332269Z",
     "start_time": "2024-10-10T14:26:33.210130Z"
    }
   },
   "cell_type": "code",
   "source": [
    "// Display a JDialog\n",
    "// Note, this will not be shown in the notebook, but will be shown as a floating window.\n",
    "// To render the JDialog inline, you will need to pull out the content panenl of the JDialog\n",
    "// but be aware that the size might be wrong.\n",
    "val dialog = JDialog()\n",
    "dialog.defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE // EXIT_ON_CLOSE doesn't work\n",
    "dialog.preferredSize = Dimension(300, 200)\n",
    "val panel = JPanel()\n",
    "//panel.preferredSize = Dimension(300, 200)\n",
    "val button1 = JButton(\"Button 1\")\n",
    "val button2 = JButton(\"Button 2\")\n",
    "val button3 = JButton(\"Button 3\")\n",
    "button1.addActionListener { panel.background = Color.RED }\n",
    "button2.addActionListener { panel.background = Color.GREEN }\n",
    "button3.addActionListener { panel.background = Color.BLUE }\n",
    "panel.add(button1)\n",
    "panel.add(button2)\n",
    "panel.add(button3)\n",
    "dialog.add(panel)\n",
    "dialog.pack()\n",
    "dialog.isVisible = true\n",
    "dialog // Dialogs are shown outside IDEA"
   ],
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlgAAAFYCAYAAACPjoJBAAAW1klEQVR4Xu3dab8cZZkHYL+POcGQRPZEEgiBBAgjy8giDCigoIIwAgqyCIo4Ki6gCIqCjooiCgoiiqiAIiiriuA6i77jN9+g59zVVtun6nTTnHM/1eXxenH9HLqq63R6/k/Vv6predWrF14zAAAgz6uaLwAAsDoKFgBAMgULACCZggUAkEzBAgBIpmABACRTsAAAkilYAADJFCwAgGQKFgBAMgULACCZggUAkEzBAgBI1vuCtbDfnsGG424ZbDz7qcHm8/862Hzh/8HqLWYpMhXZiow1cwcAq9HfgrV+02DD8bcubgxfam8cIdVLVdYic60cAsAK9LNg7bV5sPfpDy6zIYRyInORvVYeC9iwcZ/B1oN3DHbuOmaw++jjBkcdcwKsWGQoshSZimw189YVuaaEvuT7leplwRoeuWpvAKG06kjWMpnMsm79hsHWbTtaKxDIFBmLrDXzV4pc06Wu871SvStYcT5M82fBTee+MFh/6AWDdZu2teaHlYgsRaYiW0tL1kvFzsmKFcKhO48crSR2H3Xs4MCt2wcbNu0zWNhr79b8MIvITmQoshSZqvMVWetiIy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OwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJFOwAACSKVgAAMkULACAZAoWAEAyBQsAIJmCBQCQTMECAEimYAEAJPt/urC/DeFazOYAAAAASUVORK5CYII=",
      "application/vnd.idea.swing": "2"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-10-10T14:26:35.742466Z",
     "start_time": "2024-10-10T14:26:35.666954Z"
    }
   },
   "cell_type": "code",
   "source": [
    "// Display a JPanel\n",
    "// JPanels will be displayed inline in\n",
    "import java.awt.Color\n",
    "import java.awt.Dimension\n",
    "import java.awt.GraphicsConfiguration\n",
    "import java.awt.RenderingHints\n",
    "import java.awt.image.BufferedImage\n",
    "import java.io.File\n",
    "import javax.swing.*\n",
    "\n",
    "val panel = JPanel()\n",
    "panel.size = Dimension(300, 200)\n",
    "panel.preferredSize = Dimension(300, 200)\n",
    "val button1 = JButton(\"Button 2\")\n",
    "button1.size = Dimension(100, 50)\n",
    "panel.add(button1)\n",
    "panel.isVisible = true\n",
    "panel // Panels are shown inside IDEA"
   ],
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAASwAAADICAYAAABS39xVAAAIAUlEQVR4Xu3de3NV1RnAYb9Pi9xREJFLCBAgQpMRbbVqocWx0laUAapoqb14KZdKUaxSC6iIilpssWitFwSkoBRBQYGq7fRzrGbtTg4556TMZpKTzZs+fzwDe++V5Mw7k1/2Xgnhsq+NGJUAIris8QTApUqwgDCagjVy9Pg0fWZH6pjflToXLqIF8mzzjPOsG+cP/G91wcqfQHM7u1Nb+9w0ZvyV6euXj256AwYmzzTPNs84z1q0oLy6YOWv+vkTqXERrZFnnWfeeB7oX12wOjq7iq/+jYtojTzrPPPG80D/6oKV91c8Bg6dPOs888bzQP+agtW4gNYycyhPsCpm5lCeYFXMzKE8waqYmUN5glUxM4fyBKtiZg7lCVbFzBzKE6yKmTmUJ1gVM3MoT7AqZuZQnmBVzMyhPMGqmJlDeUMSrI2Pbk5bfru1sPnxJ9O9961NYydMbFp3KZkxc07atHlL2rlrd1pz/wNp4uRrmtYMhlbNHIajIQnWiU8+S7tf2VOE68mt29Kx4yfT+wcPl47Whl//N3h9z73x5ttp2Q+XN60dDFOmtaWTn36e9vV8jEfWbUz7DxxO77x3II0aM/i/bK9VM4fhaMiCdUefuEy86ur0+dkv0+Lv3lYct7XPTrM75teujxw9Ll13/Y3Fn7PmzEu7Xnw5vbJnb3Fu9NgJqat7UTr64fG0fsOm9I3u8685/7qWjnkL0neWLE1Tps6oew3XLugu7pJyjG5dvDSNv2JS0+vstabnDvD4iVPp8lFji+Op02emc1/8K13/zZua1g5Uq2YOw1ElwZpyzfR09h//TEu+d3txvOmxJ9KOZ54/f70nKl989e80vW12Wr/xN+mTU2cK7+4/VJz74959xdsfPXYivfanfcXb5JC9sPsPxfnDR44V63+0fEXtfb6z/2B69bW9xfV8Ld9B3XzLkqbXWnz8ntjNnHX+N4FOvGpKEawcysa1A9WqmcNwNGTB2rZjZ3Hn8tAjG9LBDz5ML728p4h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EIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYQhWEAYggWEIVhAGIIFhCFYQBiCBYTxH30UzXwS9XiJAAAAAElFTkSuQmCC",
      "application/vnd.idea.swing": "3"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 3
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "name": "kotlin",
   "version": "1.9.10",
   "mimetype": "text/x-kotlin",
   "file_extension": ".kt",
   "pygments_lexer": "kotlin",
   "codemirror_mode": "text/x-kotlin",
   "nbconvert_exporter": ""
  },
  "ktnbPluginMetadata": {
   "sessionRunMode": "IDE_PROCESS",
   "projectLibraries": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
